<?php
class MichomeAction extends CommonAction {
	public function index()
	{
		$Michome = M('Michome');
		$map['mid'] = $this->mid;
		$vo = $Michome->where($map)->find();
		$this->assign('vo',$vo);
		$this->getThemes();
      	cookie( '_currentUrl_', __SELF__ );
		$this->display();
	}
	public function updatefield()
	{
		$Michome = M('Michome');
		$map['mid'] = $this->mid;
		$fvalue = I('fvalue');
      	$fname = I('fname');
      	$Michome->where($map)->save($data);
	}	

	function getThemes()
    {
    	$dir = './Tpl/Mobile/';
    	$dir_handle = opendir($dir);
    	$arr=array();  
    	if($dir_handle)  
	    {  
	        // 这里必须严格比较，因为返回的文件名可能是“0”   
	        while(($file=readdir($dir_handle))!==false)  
	        {  
	            if($file==='.' || $file==='..' || strtolower($file)=='index' )  
	                continue;  
	            if(is_dir($dir.'/'.$file)){
	            	if(!is_file($dir.'/'.$file.'/index.html')) continue; 
	            	$v = array();
	                $v['tplname'] = $file;  
	                $v['preview'] = $dir.$file.'/index.jpg';  
	                $arr[] = $v;
	            }
	        }  
	        closedir($dir_handle);  
	    } 
	    $this->assign('tpllist',$arr);
    }

}